﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;

namespace DomainModel
{
    /// <summary>
    /// Représente une Panne
    /// </summary>
    public class Panne : Entity
    {
        [Required()]
        public string Code { get; private set; }

        public string Label { get; private set; }

        /// <summary>
        /// Workround pour pouvoir persister des propriétés de type Enum avec EF.4.x
        /// </summary>
        public int SeverityValue { get; private set; }

        public PanneSeverity Severity 
        {
            get { return (PanneSeverity)SeverityValue; }
            private set { SeverityValue = (int) value; } 
        }

        public Panne()
        {}

        public Panne(string code, string label, PanneSeverity severity)
        {
            Code = code;
            Label = label;
            SeverityValue = (int)severity;
        }

        public string GetSeverityDescription()
        {
            switch (Severity)
            {
                case PanneSeverity.Moderate:
                    return "Panne modérée";
                case PanneSeverity.Serious:
                    return "Panne grave";
            }
            return "n/a";
        }
    }
}
